home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / librw / RWTValHashMultiMapIterator.z / RWTValHashMultiMapIterator
Encoding:
Text File  |  1998-10-30  |  9.1 KB  |  265 lines

  1.  
  2.  
  3.  
  4. RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMuuuullllttttiiiiMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))              RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMuuuullllttttiiiiMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))
  5.  
  6.  
  7.  
  8. NNNNaaaammmmeeee
  9.      RWTValHashMultiMapIterator<K,T,H,EQ> - Rogue Wave library class
  10.  
  11. SSSSyyyynnnnooooppppssssiiiissss
  12.               #include<rw/tvhmmap.h>
  13.  
  14.  
  15.  
  16.               RWTValHashMultiMap<K,T,H,EQ> m;
  17.           RWTValHashMultiMapIterator<K,T,H,EQ> itr(m);
  18.  
  19. SSSSttttaaaannnnddddaaaarrrrdddd CCCC++++++++ LLLLiiiibbbbrrrraaaarrrryyyy DDDDeeeeppppeeeennnnddddeeeennnntttt!!!!
  20.      RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMuuuullllttttiiiiMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr requires the Standard C++ Library.
  21.  
  22.  
  23. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
  24.      RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMuuuullllttttiiiiMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr is supplied with TTTToooooooollllssss....hhhh++++++++ 7 to provide an
  25.      iterator interface to RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMuuuullllttttiiiiMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr that is backward
  26.      compatible with the container iterators provided in TTTToooooooollllssss....hhhh++++++++ 6.x.
  27.      Iteration over an RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMuuuullllttttiiiiMMMMaaaapppp is pseudorandom and dependent on the
  28.      capacity of the underlying hash table and the hash function being used.
  29.      The only useable relationship between consecutive elements is that
  30.      elements which are defined to be equivalent by the equivalence object,
  31.      EEEEQQQQ, will remain adjacent.  The current item referenced by this iterator
  32.      is undefined after construction or after a call to rrrreeeesssseeeetttt(((()))).  The iterator
  33.      becomes valid after being advanced with either a preincrement or
  34.      ooooppppeeeerrrraaaattttoooorrrr(((()))).  For both ooooppppeeeerrrraaaattttoooorrrr++++++++ and ooooppppeeeerrrraaaattttoooorrrr(((()))), iterating past the last
  35.      element will return a value equivalent to boolean ffffaaaallllsssseeee.  Continued
  36.      increments will return a value equivalent to ffffaaaallllsssseeee until rrrreeeesssseeeetttt(((()))) is
  37.      called.
  38.  
  39. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
  40.      None
  41.  
  42. EEEExxxxaaaammmmpppplllleeee
  43.               #include<rw/tvhmmap.h>
  44.  
  45.  
  46.  
  47.               #include<rw/cstring.h>
  48.           #include<iostream.h>
  49.  
  50.  
  51.               struct silly_h{
  52.  
  53.  
  54.  
  55.                  unsigned long operator()(const RWCString& x) const
  56.              { return x.length() * (long)x(0); }
  57.           };
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMuuuullllttttiiiiMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))              RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMuuuullllttttiiiiMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))
  71.  
  72.  
  73.  
  74.               int main(){
  75.  
  76.  
  77.  
  78.                  RWTValHashMultiMap
  79.                <RWCString,int,silly_h,equal_to<RWCString> > age;
  80.              RWTValHashMultiMapIterator
  81.                <RWCString, int, silly_h, equal_to<RWCString > > itr(age);
  82.  
  83.  
  84.                  age.insert(RWCString("John"), 30);
  85.  
  86.  
  87.  
  88.                  age.insert(RWCString("Steve"),17);
  89.              age.insert(RWCString("Mark"),24);
  90.              age.insert(RWCString("Steve"),24);
  91.  
  92.  
  93.                  for(;itr();)
  94.  
  95.  
  96.  
  97.                    cout << itr.key() << "'s age is " << itr.value() << endl;
  98.  
  99.  
  100.  
  101.                  return 0;
  102.  
  103.  
  104.  
  105.               }
  106.  
  107.  
  108.  
  109.               Program Output (not necessarily in this order)
  110.  
  111.  
  112.  
  113.               John's age is 30
  114.           Steve's age is 24
  115.           Steve's age is 17
  116.           Mark's age is 24
  117.  
  118. PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss
  119.               RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMuuuullllttttiiiiMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr<<<<KKKK,,,,TTTT,,,,HHHH,,,,EEEEQQQQ>>>>
  120.  
  121.  
  122.  
  123.               (RWTValHashMultiMap<K,T,H,EQ>&h);
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMuuuullllttttiiiiMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))              RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMuuuullllttttiiiiMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.      Creates an iterator for the hash multimap hhhh.  The iterator begins in an
  144.      undefined state and must be advanced before the first element will be
  145.      accessible.
  146.  
  147. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr OOOOppppeeeerrrraaaattttoooorrrrssss
  148.               RWBoolean
  149.           ooooppppeeeerrrraaaattttoooorrrr(((())))();
  150.  
  151.  
  152.      Advances sssseeeellllffff to the next element, dereferences the resulting iterator
  153.      and returns ffffaaaallllsssseeee if the iterator has advanced past the last item in the
  154.      container and ttttrrrruuuueeee otherwise.
  155.  
  156.               RWBoolean
  157.           ooooppppeeeerrrraaaattttoooorrrr++++++++();
  158.  
  159.  
  160.      Advances sssseeeellllffff to the next element.  If the iterator has been reset or
  161.      just created sssseeeellllffff will now reference the first element.  If, before
  162.      iteration, sssseeeellllffff referenced the last association in the multimap, sssseeeellllffff
  163.      will now reference an undefined value and ffffaaaallllsssseeee will be returned.
  164.      Otherwise, ttttrrrruuuueeee is returned. Note: no postincrement operator is provided.
  165.  
  166. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
  167.               RWTValHashMultiMap<K,T,H,EQ>*
  168.           ccccoooonnnnttttaaaaiiiinnnneeeerrrr(((()))) const;
  169.  
  170.  
  171.      Returns a pointer to the collection being iterated over.
  172.  
  173.               K
  174.           kkkkeeeeyyyy() const;
  175.  
  176.  
  177.      Returns the key portion of the association currently referenced by sssseeeellllffff.
  178.  
  179.               void
  180.           rrrreeeesssseeeetttt();
  181.           void
  182.           rrrreeeesssseeeetttt(RWTValHashMultiMap<K,T,H,EQ>& h);
  183.  
  184.  
  185.      Resets the iterator so that after being advanced it will reference the
  186.      first element of the collection.  Using rrrreeeesssseeeetttt(((()))) with no argument will
  187.      reset the iterator on the current container.  Supplying a
  188.      RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMuuuullllttttiiiiMMMMaaaapppp with rrrreeeesssseeeetttt(((()))) will reset the iterator on that
  189.      container.
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMuuuullllttttiiiiMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))              RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMuuuullllttttiiiiMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))
  203.  
  204.  
  205.  
  206.               T
  207.           vvvvaaaalllluuuueeee();
  208.  
  209.  
  210.      Returns the value portion of the association referenced by sssseeeellllffff.
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.